package likou.jindian;

import java.util.HashSet;
import java.util.Set;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/05/20 15:28
 */
public class _16_21 {
    public int[] findSwapValues(int[] array1, int[] array2) {
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        int sum1=0,sum2=0;
        for (int j : array1) {
            set1.add(j);
            sum1 += j;
        }
        for (int j : array2) {
            set2.add(j);
            sum2 += j;
        }
        int p = sum1-sum2;
        for (Integer integer : set1) {
            if (set2.contains(integer-p)){
                return new int[]{integer,integer-p};
            }
        }
        return new int[0];
    }
}
